import { ISelectOption } from '../../types';
import React from 'react';

export interface IBaseProps<ValueType = any> {
  disabled?: boolean;
  value?: ValueType;
  onChange?: (value: ValueType) => void;
}

export interface ISelectProps extends IBaseProps<string | number | string[]> {
  options?: ISelectOption[];
  hasUnselectedOption?: boolean;
  multiple?: boolean;
  type?: string;
}

export interface IJSONFormProps {
  readonly: boolean;
  initName: string; // Surface Behavior 等
  formFormat: any; // 表单格式， 比如：{ Type:{ "Hard": {}, "Linear": {...}, ...} 包含多个键值的JSON对象
  formData?: any; // 用户保存的表单数据 ，比如：{"Type": "Hard", "Value": {}}
  onChange: (name: string, value: any) => void;
  indicesAssigned?: Set<string>; // 保存已被使用的entity index
  switchedOnEntityGroup?: string; // 切换entityGroup
  onSwitchEntityGroup?: (name: string) => void; // 切换entityGroup回调
}

export interface IColumsList {
  title: string;
  dataIndex: string;
}

export interface ITableProps {
  table: [];
  tableType?: string;
  value?: string | number | string[] | TableDataType[];
  hasUnselectedOption?: boolean;
  disabled?: boolean;
  multiple?: boolean;
  type?: string;
  dataSource?: [];
  columns?: IColumsList[];
  onChange?: (
    value: string | number | string[] | TableDataType[] | object,
  ) => void;
}

export interface EditableRowProps {
  index: number;
}

export interface EditableCellProps {
  title: React.ReactNode;
  editable: boolean;
  children: React.ReactNode;
  dataIndex: any;
  record: any;
  handleSave: (record: any) => void;
}

export interface TableDataType {
  key: React.Key;
  YieldStress?: number;
  PlasticStrain?: number;
}
